/**
 * 
 */
package TestScenario;

import java.util.Calendar;

import ptvv.*;
import ptvv.system.DefPortAutomaton;
import ptvv.system.OutputPort;
import ptvv.system.TracePacket;

/**
 * @author dkz
 * 
 */
public class Move extends DefPortAutomaton {
	// variables needed for computation

	public Move(String name) {
		this.setName(name);

		// outputPort = new OutputPort(destination, dest);

	}

	public void starting() throws InterruptedException {
		//System.out.println("move start");

		eventQueue.take(); // waiting for start
		// System.out.println(item);

	}

	public void ready() throws InterruptedException {
		//System.out.println("move ready");
		message = this.inputPorts.get(0).queue.take();
		//System.out.println("move done ready");

	}

	public void running() throws InterruptedException {
		Calendar cal = Calendar.getInstance();
		int count = 0;
		try {
			while (true) {
				Thread.sleep(1000);
				count++;
				System.out.println("still sleeping");
				
				// logger.log("Moving in direction: " + message + " for: " +
				// count
				// + "seconds");
			}

		} catch (InterruptedException ie) {
			System.out.println("Moving Interrupted");
		}

		// System.out.println("sleeping..");
		// System.out.println("awake");
		// this.internalState = InternalStates.Suspended;
	}

	public void suspended() throws InterruptedException {

	}

	public void end() {
		// // System.out.println("end");
		TracePacket tp = new TracePacket(this.getName());
		tp.addData(message);
		logger.packet(tp);
		logger.log(this.getName() + ": " + message);
		
		// repeatBool = true;
	}

	public void dead() {
		// this.internalState = InternalStates.Start;

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}

}
